// import { defineConfig } from 'vite'
// import uni from '@dcloudio/vite-plugin-uni'
// // https://vitejs.dev/config/
// export default defineConfig({
//   plugins: [
//     uni(),
//   ],
// })
// import {
//   loadEnv
// } from 'vite';
import { loadEnv } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import path from 'path';
// import viteCompression from 'vite-plugin-compression';
import uniReadPagesV3Plugin from './src/sheep/router/utils/uni-read-pages-v3';
// import mpliveMainfestPlugin from './sheep/libs/mplive-manifest-plugin';

// https://vitejs.dev/config/
export default (command, mode) => {
  const env = loadEnv(mode, __dirname, 'PROJECT_');
  return {
    envPrefix: "PROJECT_",
    plugins: [
      uni(),
      // viteCompression({
      // 	verbose: false
      // }),
      uniReadPagesV3Plugin({
        pagesJsonDir: path.resolve(__dirname, './src/pages.json'),
        includes: ['path', 'aliasPath', 'name', 'meta'],
      }),
      // mpliveMainfestPlugin(env.PROJECT_MPLIVE_ON)
    ],
    server: {
      host: true,
      // open: true,
      port: env.PROJECT_DEV_PORT,
      hmr: {
        overlay: true,
      },
    },
  };
};

export const build = {
  rollupOptions:{
    external:["luch-request","qs-canvas"]
  }
};